package com.data.web.controller.sensor.commom;


import com.data.biz.domain.BizFan;
import com.data.biz.domain.Function;
import com.data.biz.domain.WindPoint;
import com.data.biz.service.IBizSensorCommonService;
import com.data.biz.vo.SensorVo.common.FanGeneralDataVo;
import com.data.web.constant.ResultVo;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/sensor/commom")
public class SensorCommomController {

    @Autowired
    private IBizSensorCommonService commomService;


    @ApiOperation(value = "获取风机列表", notes = "获取风机列表", httpMethod = "GET", consumes = "application/x-www-form-urlencoded")
    @RequestMapping("/getFanListForSensor")
    @ResponseBody
    public List<BizFan> getFanListForSensor() {
        return commomService.getFanlist(null);
    }

    @ApiOperation(value = "获取测项列表", notes = "获取测项列表", httpMethod = "GET", consumes = "application/x-www-form-urlencoded")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "fanId", value = "风机ID", required = true, dataType = "int", paramType = "query"),
    })
    @RequestMapping("/getFunctionListForFan")
    @ResponseBody
    public List<Function> getFunctionListForFan(Integer fanId) {
        return commomService.selectFunctionList(fanId);
    }




    @ApiOperation(value = "获取测点列表", notes = "获取测点列表", httpMethod = "GET", consumes = "application/x-www-form-urlencoded")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "fanId", value = "风机ID", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "functionId", value = "测项ID", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pointName", value = "测点名称", required = false, dataType = "int", paramType = "query"),

    })
    @RequestMapping("/getPointListForSensor")
    @ResponseBody
    public List<WindPoint> getPointListForSensor(Integer fanId, Integer functionId, String pointName) {
        return commomService.selectPointList(fanId,functionId,pointName);
    }


    @ApiOperation(value = "获取风机实时数据", notes = "获取风机实时数据", httpMethod = "GET", consumes = "application/x-www-form-urlencoded")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "fanId", value = "风机ID", required = true, dataType = "int", paramType = "query"),
    })
    @RequestMapping("/getFanGeneralData")
    @ResponseBody
    public ResultVo<FanGeneralDataVo> getFanGeneralData(Integer fanId) {

        FanGeneralDataVo result = commomService.getFanGeneralData(fanId);
        return ResultVo.success(result);
    }

}
